package com.hifar.test.entrust.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hifar.test.entrust.mapper.HfEnvGkPieceMapper;
import com.hifar.test.entrust.pojo.HfEnvGkPiece;
import com.hifar.test.entrust.service.IHfEnvGkPieceService;
import com.hifar.test.task.pojo.HfEnvTask;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 委托单样品 服务实现类
 * </p>
 *
 * @author wei
 * @since 2024-12-04 15:51:56
 */
@Service
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public class HfEnvGkPieceServiceImpl extends ServiceImpl<HfEnvGkPieceMapper, HfEnvGkPiece> implements IHfEnvGkPieceService {

	@Override
	public void removeByGkEntrustId(String gkEntrustId) {
		QueryWrapper<HfEnvGkPiece> queryWrapper = new QueryWrapper<>();
		queryWrapper.lambda()
				.eq(HfEnvGkPiece::getGkEntrustId, gkEntrustId);
		this.remove(queryWrapper);
	}

	@Override
	public List<HfEnvGkPiece> listByGkEntrustId(String gkEntrustId) {
		QueryWrapper<HfEnvGkPiece> queryWrapper = new QueryWrapper<>();
		queryWrapper.lambda()
				.eq(HfEnvGkPiece::getGkEntrustId, gkEntrustId)
				.orderByAsc(HfEnvGkPiece::getRowSort);
		return this.list(queryWrapper);
	}

	@Override
	public void updateEntrustId(String gkEntrustId, String entrustId) {
		this.lambdaUpdate()
				.set(HfEnvGkPiece::getEntrustId, entrustId)
				.eq(HfEnvGkPiece::getGkEntrustId, gkEntrustId)
				.update();
	}
}
